package com.ikcai.controller;

import com.ikcai.pojo.University;
import com.ikcai.service.impl.IUniversityService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhaoli on 2017/8/15.
 */
@Controller
public class UniversityController {

    @Resource
    private IUniversityService service;

    @RequestMapping(value = "/universityInfo",  method = RequestMethod.POST)
    public void orderinfo(String requestBody ) {
        try {
            University university = service.getUniversityByPrimaryKey(2);
            System.out.println(university.toString());
        }catch (Exception e)
        {
            System.out.println("error.........");
        }finally {
            System.out.println("abc");
        }

    }

    @RequestMapping(value = "/university")
    public String toUniversity (HttpServletRequest request, HttpServletResponse response, Model model){
        List<University> list = service.getUniversityList(1,100);
        model.addAttribute("list",list);
        return "university";
    }

}
